const flag = 'getComputedStyle' in window

// 获取上一个兄弟元素
export function prev (curEle) {
  if (flag) { // IE6~8的情况
    return curEle.previousElementSibling
  }
  let pre = curEle.previousSibling
  while (pre && pre.nodeType !== 1) {
    pre = pre.previousSibling
  }
  return pre
}

// 获取下一个兄弟元素
export function next (curEle) {
  if (flag) { // IE6~8的情况
    return curEle.nextElementSibling
  }
  let nex = curEle.nextSibling
  while (nex && nex.nodeType !== 1) {
    nex = nex.nextSibling
  }
  return nex
}

// 获取当前元素前面的所有兄弟元素
export function prevAll (curEle) {
  const ary = []
  let pre = prev(curEle)
  while (pre) {
    ary.unshift(pre)
    pre = prev(pre)
  }
  return ary
}
